﻿using GSBA.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GSBA.ViewModels
{
    /// <summary>
    /// Navigation category
    /// A navigation category is a collection of navigation tiles in the view model
    /// </summary>
    public class NavigationCategory
    {

        public NavigationCategory(int _index, string _name)
        {
            this.Category = _name;
            this.CategoryIndex = _index;
            this.Items = new List<NavigationItem>();
            this.CategoryCommand = new NavigationCommand<object>((o) => NavigationService.GetInstance().Navigate(_name+"View"));
        }

        public string Category
        {
            get;
            set;
        }

        public IList<NavigationItem> Items
        {
            get;
            set;
        }

        public int CategoryIndex
        {
            get;
            set;
        }

        public NavigationCommand<object> CategoryCommand
        {
            get;
            set;
        }
    }

    /// <summary>
    /// Navigation item
    /// A navigation item is the model for the tile in the main navigation page
    /// </summary>
    public class NavigationItem
    {

        public NavigationItem(string _name, string _description, string _imagePath, string _background, NavigationCategory _category)
        {
            this.Name = _name;
            this.Description = _description;
            this.Image = _imagePath;
            this.BackgroundResource = _background;
            this.Category = _category;
            this.Category.Items.Add(this);
        }

        public string Name
        {
            get;
            set;
        }

        public string Description
        {
            get;
            set;
        }

        public string Image
        {
            get;
            set;
        }

        public string BackgroundResource
        {
            get;
            set;
        }

        public NavigationCategory Category
        {
            get;
            set;
        }

        public NavigationCommand<object> ItemCommand
        {
            get;
            set;
        }

        internal bool IsMatchForFilter(string queryText)
        {
            return Name.ContainsIgnoreCase(queryText);
        }
    }
}
